package com.zhongge.binarytreeOJ;

/**
 * @ClassName TestBinaryTree
 * @Description TODO 测试二叉树
 * @Author zhongge
 * @Date 2025/9/1 16:20
 * @Version 1.0
 */
public class TestBinaryTree {
    public static void main(String[] args) {
        MyBinaryTree tree = new MyBinaryTree();
        //手动创建二叉树
        MyBinaryTree.TreeNode binaryTree = tree.createBinaryTree();
        int[] preOrder = {3,9,20,15,7};
        int[] inOrder = {9,3,15,20,7};
        MyBinaryTree.TreeNode treeNode = tree.buildTree(preOrder, inOrder);

        //遍历
        tree.inOrder(treeNode);
    }
    public static void main1(String[] args) {
        MyBinaryTree tree = new MyBinaryTree();
        //手动创建二叉树
        MyBinaryTree.TreeNode binaryTree = tree.createBinaryTree();
        //遍历
        tree.preOrder(binaryTree);
        System.out.println();
        System.out.println("================");
        tree.inOrder(binaryTree);
        System.out.println();
        System.out.println("================");
        tree.postOrder(binaryTree);
        System.out.println();
        System.out.println("=================");
        System.out.println("二叉树的节点个数（子问题思路）：" + tree.nodeSize(binaryTree));
        tree.nodeSizeOfOrder(binaryTree);
        System.out.println("二叉树的节点个数（遍历思想）：" + MyBinaryTree.nodeSize);

        System.out.println("============非递归实现遍历=========");
        System.out.print("非递归实现前序遍历 :");
        tree.preOrderNoRec(binaryTree);
        System.out.println();
        System.out.print("非递归实现中序遍历 :");
        tree.inOrderNoRec(binaryTree);
        System.out.println();
        System.out.print("非递归实现后序遍历 :");
        tree.postOrderNoRec(binaryTree);
        System.out.println();
        System.out.println("================================");
    }
}
